// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'element-ui/lib/theme-chalk/display.css'
import VueI18n from 'vue-i18n'
import App from './App'
import VueRouter from 'vue-router'
import routes from './router/index'

import './assets/style/style.css'
import './assets/iconfont/iconfont.css'


import hljs from 'highlight.js' //导入代码高亮文件
import 'highlight.js/styles/monokai-sublime.css'  //导入代码高亮样式
//自定义一个代码高亮指令
Vue.directive('highlight',function (el) {
  let highlight = el.querySelectorAll('pre code');
  highlight.forEach((block)=>{
      hljs.highlightBlock(block)
  })
})

// highlight.js代码高亮插件
// import Highlight from './utils/highlight'; // from 路径是highlight.js的路径，纯属自定义
// Vue.use(Highlight);

Vue.config.productionTip = false

Vue.use(ElementUI);
Vue.use(VueI18n);
Vue.use(VueRouter);

// 路由地址去  /#/
const router = new VueRouter({
  linkActiveClass: 'is-active',
  routes,
  mode: 'history'
})

// 多语言，暂时只有中文
const i18n = new VueI18n({
  locale: 'zh',
  messages: {
    'zh': require('./lang/zh'),
  }
})

//当路由跳转页面后返回顶部
router.afterEach((to, from, next) => {
  window.scrollTo(0,0)
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  i18n,
  components: { App },
  template: '<App/>'
})
